package friend

import (
	"day12_12_homework/internal/api/request"
	"day12_12_homework/internal/models/service"
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func FindCreateFriends(c *gin.Context) {
	var json request.FriendCreateResponse
	if err := c.ShouldBindJSON(&json); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	value, _ := c.Get("userId")

	fmt.Println(value)

	create, s := service.FriendCreate(json.NickName, value)
	if s != "" {
		c.JSON(http.StatusBadRequest, gin.H{
			"message": s,
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"message": create,
	})

}
